# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-demjson
pkgname=('python2-demjson' 'python-demjson')
_pkgname=demjson
pkgver=2.2.4
pkgrel=11
pkgdesc='Encoder, decoder, and lint/validator for JSON (JavaScript Object Notation) compliant with RFC 4627.'
arch=('any')
url='https://pypi.org/project/demjson/#files'
license=('LGPL')
makedepends=('python2-setuptools' 'python-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz"
        'setup.py.patch')
sha512sums=('d8a1cde062d0b062bdae29b6d79ad69fb9cc185428718a0009ccbed544ed37bd354fbb86edadb56bd98183ac8636b2edae322ed19aa5f07a7b6df668c7aa0029'
            '9d6fe4f2b0edf2222552ced6ecf56df5b0af566a0a5ad856f367e2afe6ffb5c150158420258632837af244769264c7992f3094fdcaf5669187628488f4b264fb')

prepare() {
  patch -p1 < setup.py.patch
  cp -a "$_pkgname-$pkgver"{,-2}
}

build() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname-$pkgver"

  python setup.py build
}

package_python2-demjson() {
  depends=('python2')

  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  mv "$pkgdir/usr/bin/jsonlint" "$pkgdir/usr/bin/jsonlint2"
}

package_python-demjson() {
  depends=('python')

  cd "$_pkgname-$pkgver"

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
}

